
#include "gamemanager.h"
#include "resourcemanager.h"
#include "messagequeue.h"
#include "log.h"
#include "unit.h"
#include "gamescene.h"

GameManager* GameManager::_instance = nullptr;

GameManager::GameManager() :
xscale(0.0f)
, yscale(0.0f)
, minscale(0.0f)
{
    screenSize = CCDirector::sharedDirector()->getWinSize();
    xscale = screenSize.width / BASE_WIDTH;
    yscale = screenSize.height / BASE_HEIGHT;
    minscale = (xscale < yscale ? xscale : yscale);

	dpi = CCDevice::getDPI();

	_DHLOG("width: %0.0f, height:%0.0f, x scale:%0.2f, y scale:%0.2f, min scale:%0.2f, dpi:%d", screenSize.width, screenSize.height, xscale, yscale, minscale, dpi);
}

GameManager::~GameManager() {

}

GameManager* GameManager::getInstance() {
    if (_instance == nullptr) {
        _instance = new GameManager();
    }
    return _instance;
}

void GameManager::startBattle() {

}

void GameManager::endBattle() {

}

bool GameManager::floatEquals(float a, float b) {
	bool ret = (static_cast<float>(fabs(a - b)) < 0.01f);
	return ret;
}

bool GameManager::pointEquals(const CCPoint &a, const CCPoint &b) {
	bool ret1 = floatEquals(a.x, b.x);
	bool ret2 = floatEquals(a.y, b.y);

	return ret1 && ret2;
}
